//-----------------------------------------------------------------------------
//              table onload initializer routines
//-----------------------------------------------------------------------------
function initTable(tableId)
{
   //setScrollProperty(tableId);
   // Get the table section to filter
   var tBody = document.getElementById(tableId);
   var oldDsply = tBody.style.display;
   var columnsToFilterFld = document.getElementById(tableId + datatableFilteredColumns);
   var columnsToSortFld = document.getElementById(tableId + datatableSortedColumns);
   var selectColumnFld = document.getElementById(tableId + datatableSelectColumn);
   tBody.lastColumn = -1;

   if (selectColumnFld != null)
   {
      tBody.selectColumn = parseInt(selectColumnFld.value);
      if (isNaN(tBody.selectColumn))
         tBody.selectColumn = -1;
   }
   else
      tBody.selectColumn = -1;

   var numColumns = tBody.rows[0].cells.length;

   for (c = 0; c < numColumns;c++)
   {
      var colObj = document.getElementById(tableId + c);
      if (colObj != null)
      {
         colObj.filterValue = "All";
         colObj.lastSelectedIndex = 0;
      }
   }
   if (columnsToSortFld != null)
   {
      var columnsToSort = columnsToSortFld.value.split(datatableOnLoadDivider);
      // save standard header to be restored after sort

      for (var i = 0; i <  columnsToSort.length; i++)
      {
         var sortInfo = columnsToSort[i].split(datatableOnLoadSubDivider);
         if (sortInfo.length == 2)
         {
            var sortColumn = sortInfo[0];
            var thID = tableId + sortColumn;
            var thObj = document.getElementById(thID);
            // sorting once results in values increasing
            // as cell positions go down in table
            // sorting twice reverses this i.e.
            // 0 = no column to sort
            // 1 = sort (descending)
            // 2 = and reveres (ascending)
            var sortDirection = sortInfo[1];
            if (sortDirection > 2)
               sortdirection = 2;
            if ( i > 0)
            {
               for (var d = 0; d < sortDirection; d++)
               {
                  doCumulativeSort(tBody, thObj, sortColumn);
               }
            }
            else
            {
               for (var d = 0; d < sortDirection; d++)
               {
                  doSort(tBody, thObj, sortColumn);
               }
            }
         }
      }
   }
   if (columnsToFilterFld != null)
   {
      var columnsToFilter = columnsToFilterFld.value.split(datatableOnLoadDivider);

      for (var i = 0; i <  columnsToFilter.length; i++)
      {
         var filterInfo = columnsToFilter[i].split(datatableOnLoadSubDivider);
         if (filterInfo.length == 3)
         {
            var filterColumn = filterInfo[0];
            var filterIndex = filterInfo[1];
            var filterString = filterInfo[2];
            doFilterTable(tBody, filterColumn, filterIndex, filterString);
         }
      }
   }
   resetSelectedAll(tBody);
   // Set the table display style to "none" - necessary for Netscape 6
   // browsers.

   tBody.style.display = "none";

   // restore odd even colors
   setRowClass(tBody);

   // Restore the tables display style.
   tBody.style.display = oldDsply;
   document.body.style.cursor = "default";
   }
